package com.app.car.home;

import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import com.app.car.R;
import com.app.car.basis.Constants;
import com.app.car.bean.BaseInfoUpdateCache;
import com.app.car.check.CheckIndexActivity;
import com.app.car.dialog.UpdateBaseInfoDialog;
import com.app.car.greendao.GreenDaoUtils;
import com.app.car.util.MyUtils;
import com.qmuiteam.qmui.util.QMUIStatusBarHelper;
import butterknife.OnClick;
import my.ActivityTool;

/**
 * 首页
 */
public class HomeIndexActivity extends HomeBaseActivity {


    @Override
    public void initViews() {
        super.initViews();
        setContentView(R.layout.home_index_activity);
    }

    @Override
    public void initData(Bundle savedInstanceState) {
        super.initData(savedInstanceState);
        setTitleBg(R.color.transparent);
        QMUIStatusBarHelper.setStatusBarDarkMode(mContext);
        setTitle("盘点车");
//        checkCacheAndDownload();
        //弹出申请权限
        if (Build.VERSION.SDK_INT >= 23) {
            int REQUEST_CODE_CONTACT = 101;
            String[] permissions = {Manifest.permission.WRITE_EXTERNAL_STORAGE};
            //验证是否许可权限
            for (String str : permissions) {
                if (this.checkSelfPermission(str) != PackageManager.PERMISSION_GRANTED) {
                    //申请权限
                    this.requestPermissions(permissions, REQUEST_CODE_CONTACT);
                    return;
                }
            }
        }



    }


    void checkCacheAndDownload() {
        GreenDaoUtils.clearAll();
        BaseInfoUpdateCache beanNew = new BaseInfoUpdateCache();
        UpdateBaseInfoDialog.toBaseInfoUpdateDialog(mContext, beanNew);
    }

    @OnClick({R.id.view_exit, R.id.view_check, R.id.view_set, R.id.view_about, R.id.view_goods, R.id.view_get_data, R.id.view_tea})
    public void btnClick(View v) {
        switch (v.getId()) {
            case R.id.view_exit:
                System.exit(0);
                break;
            case R.id.view_set:
                break;
            case R.id.view_check:
                ActivityTool.skipActivity(mContext, CheckIndexActivity.class);
                break;
            case R.id.view_about:
                break;
            case R.id.view_goods:
                break;
            case R.id.view_get_data:
                switch (MyUtils.getModule()){
                    case Constants.OFFLINE:

                        break;
                    case Constants.ONLINE:

                        break;
                }
                break;
            case R.id.view_tea:
                break;
            default:
                break;
        }
    }

}

